<?php 
$this->lang->load('admin_admin', $this->session->admin_language);
$this->load->view('admin/layout/head', array('title'=>$this->lang->line('password')), FALSE);
?>

<div id="container">
<ul class="nav nav-tabs" id="subject-tab">
	<li class="active"><a href="javascript:;"><?php echo $this->lang->line('password') ?></a></li>
</ul>
<form class="form-inline deal-from container-fluid no-padding" id="pass-form">
	<div class="mt-20">
		<label for=""><?php echo $this->lang->line('old_password') ?></label>
		<div class="form-group">
			<input type="password" name="old" class="form-control" value="" style="width: 300px">
		</div>
	</div>
	<div class="mt-20">
		<label for=""><?php echo $this->lang->line('new_password') ?></label>
		<div class="form-group">
			<input type="password" name="new" class="form-control" value="" style="width: 300px">
		</div>
	</div>
	<div class="mt-20">
		<label for=""><?php echo $this->lang->line('new_password2') ?></label>
		<div class="form-group">
			<input type="password" name="new2" class="form-control" value="" style="width: 300px">
		</div>
	</div>

	<div style="padding-left:110px" class="mt-20">
      <a href="javascript:;" class="btn btn-primary save"><?php echo $this->lang->line('save') ?></a>
      
    </div>

	
</form>
</div>


<?php 

$this->load->view('admin/layout/footer');
?>
<script type="text/javascript">

	$('.save').click(function(event) {
		
		
		if(!$('input[name=old]').val()){
			alert('<?php echo $this->lang->line('submit_error_old') ?>');
			return;
		}
		if(!$('input[name=new]').val()){
			alert('<?php echo $this->lang->line('submit_error_new') ?>');
			return;
		}
		if($('input[name=new2]').val() != $('input[name=new]').val()){
			alert('<?php echo $this->lang->line('submit_error_new2') ?>');
			return;
		}

		Toast.loading();
		$.post('/admin/admin/password', $('#pass-form').serialize(), function(data, textStatus, xhr) {
			Toast.destory();
			var json = $.parseJSON(data);
			if(json.code == 1){
				alert('<?php echo $this->lang->line('submit_error_password') ?>');
				return;
			}
			if(json.code == 2){
				alert('<?php echo $this->lang->line('submit_error_input') ?>');
				return;
			}
			if(json.code == 3){
				alert('<?php echo $this->lang->line('submit_error_new2') ?>');
				return;
			}
			Toast.success('<?php echo $this->lang->line('submit_success') ?>')

		});
	});
</script>